package com.kischang.blog.service;

import com.kischang.blog.dao.ReviewDao;
import com.kischang.blog.model.Review;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

@Component
public class ReviewService {
	@Autowired
	private ReviewDao reviewDao;
	@Resource
	private SessionFactory sessionFactory;
	
	@Transactional
	public void save(Review review){
		sessionFactory.getCurrentSession().save(review);
	}

	@Transactional(readOnly=true)
	public Review getReviewById(int pid) {
		return (Review) sessionFactory.getCurrentSession().get(Review.class, pid);
	}
}
